﻿using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Metadata.Edm;
using System.Linq;

namespace DynamicFiltering
{

    public class NavigationItem
    {
        public string FromEntity { get; set; }
        public string ToEntity { get; set; }
        public RelationshipMultiplicity FromMultiplicity { get; set; }
        public RelationshipMultiplicity ToMultiplicity { get; set; }
        public string ForeignKeyColumn { get; set; }
        public string PrimaryKeyColumn { get; set; }
        public EntitySetBase EntitySet { get; set; }
        public bool ForeignKeyNullable { get; set; }

        /// <summary>
        /// Entity type may be "Formula"; entity set may be "Formulae"
        /// </summary>
        public string EntitySetName { get { return EntitySet == null ? string.Empty : EntitySet.Name; } }

        /// <summary>
        /// In a chain of navigation items, those in the middle (excluding first and last) always reference the previous entity.
        /// This Nav item will be the one that points the opposite way.
        /// See EntityModelNavigator.AugmentMiddleChainReferences
        /// </summary>
        public NavigationItem CorrespondingForwardNav { get; set; }

#if (DEBUG)
        public override string ToString()
        {
            return string.Format( "{0} -> {1}", FromEntity, ToEntity );
        }
#endif
    }

}
